package com.woniuxy.util;

import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;

import java.util.List;

public class ValidatedUtil {

    public static void ValidatedException(BindingResult result) {
        if (result.hasErrors()) {
            List<ObjectError> allErrors = result.getAllErrors();
            allErrors.forEach(error -> {
                System.out.println(error.getDefaultMessage());
            });
            throw new WoniuActiveCodeException("参数错误", 20021);
        }
    }
}
